
import nw from "nw-lafjs";
import {fail, ok} from "@/utils/responseUtil";
export default async function (ctx: FunctionContext) {
  let body = ctx.body
  /**
   * {
   *   "_id": "12",
   *   "publishStatus": 1,  //发布
   *   "checkStatus": 1, //审核状态
   *   "isNewPerson": 1 //新人专享
   * }
   */
  if (nw.util.isNull(body._id)){
    return fail("数据不合法")
  }
  let dataJson = {}
  if (!nw.util.isNull(body.publishStatus)){
    // @ts-ignore
    dataJson.publishStatus = body.publishStatus
  }
  if (!nw.util.isNull(body.checkStatus)){
    // @ts-ignore
    dataJson.checkStatus = body.checkStatus
  }
  if (!nw.util.isNull(body.isNewPerson)){
    // @ts-ignore
    dataJson.isNewPerson = body.isNewPerson
  }
  let count = await nw.db.update({
    dbName:"skuInfo",
    whereJson:{_id:body._id},
    dataJson:dataJson
  })
  if (count===0){
    return fail("修改失败")
  }
  return ok("修改成功")

}
